﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LeadTeam.Exam.Entities;

namespace LeadTeam.Exam.AdminTool
{
    public class OrganizationsManagePanelController:BaseController
    {
        
        public OrganizationsManagePanel view;
        public Organizations model;

        public OrganizationsManagePanelController(OrganizationsManagePanel view,IMainFormView iMainFormView):base(iMainFormView)
        {
            //set view
            this.view = view;
            //set controller for the view
            this.view.Controllor = this;
            this.model = new Organizations();
           
        }

        public IMainFormView MainFormHandle
        {
            get { return base.iMainFormView; }
        }

        public void DeleteEntity()
        {
            SetRequestState();

            RequestHelper.RequestInvoke<string>((ConfigHelper.GetRootServiceUrl() + "Organization/" + model.O_ID),
                RequestMethod.DELETE, string.Empty);

            SetDoneState();
        }

        public void UpdateEntityAsParent()
        {
            SetRequestState();
            RequestHelper.RequestInvoke((ConfigHelper.GetRootServiceUrl() + "Organization/UpdateAsParent/" + model.O_ID + "/" + model.O_PARENT_ID),
               RequestMethod.PUT);
            SetDoneState();
        }

        public void UpdateEntityAsChild()
        {
            SetRequestState();
            RequestHelper.RequestInvoke((ConfigHelper.GetRootServiceUrl() + "Organization/UpdateAsChild/" + model.O_ID + "/" + model.O_PARENT_ID),
               RequestMethod.PUT);
            SetDoneState();
        }

    }
}
